package com.huawei.appmarket.service.alarm;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.huawei.appmarket.service.alarm.control.BaseNetworkStateChangeService;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import o.dha;
import o.dhq;
import o.Logger;
import o.ContentManager;
import o.ewm.n;

public class NetworkStateChangeReceiver extends SafeBroadcastReceiver {
    private static final Handler ˋ = new Handler(Looper.getMainLooper()) {
        public void handleMessage(Message message) {
            super.handleMessage(message);
            if (1 == message.what) {
                try {
                    Context ˋ = ContentManager.getInstant().getContext();
                    Intent intent = new Intent(ˋ, dha.ˋ(ˋ.getString(n.ﾞˊ)));
                    intent.putExtra(BaseNetworkStateChangeService.NET_CHANGE_INTENT_TYPE_KEY, 1);
                    ˋ.startService(intent);
                } catch (SecurityException e) {
                    Logger.e("NetworkStateChangeReceiver", "can not startService");
                } catch (Exception e2) {
                    Logger.e("NetworkStateChangeReceiver", "start Service exception");
                }
            }
        }
    };

    public void onReceiveMsg(Context context, Intent intent) {
        if (context == null) {
            Logger.ˎ("NetworkStateChangeReceiver", "context is null");
        } else if (!dhq.ॱ().ˎ()) {
            Logger.ˏ("NetworkStateChangeReceiver", "has not agree protocol");
        } else if ("android.net.wifi.STATE_CHANGE".equals(intent.getAction())) {
            Logger.ˏ("NetworkStateChangeReceiver", "onReceive:android.net.wifi.STATE_CHANGE");
            Message obtainMessage = ˋ.obtainMessage(1);
            ˋ.removeMessages(1);
            ˋ.sendMessageDelayed(obtainMessage, 2000);
        }
    }
}
